<template>
<div v-if="status != 30">
    <el-dialog
      :title="$t('plus.withdraw_review')"
      v-model="dialogVisible"
      @close="dialogFormVisible(true)"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
    >
      <el-form :model="form">
        <el-form-item :label="$t('plus.review_status')" :label-width="formLabelWidth">
          <div>
            <el-radio v-model="form.applyStatus" label="20">{{$t('plus.review_approved')}}</el-radio>
            <el-radio v-model="form.applyStatus" label="30">{{$t('plus.rejected')}}</el-radio>
          </div>
        </el-form-item>
        <div v-if="form.applyStatus == 30">
          <el-form-item :label="$t('plus.reject_reason')" :label-width="formLabelWidth"
            ><el-input v-model="form.rejectReason" autocomplete="off"></el-input
          ></el-form-item>
        </div>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="dialogFormVisible">{{$t('plus.cancel')}}</el-button>
          <el-button type="primary" @click="editApplyStatus">{{$t('plus.confirm')}}</el-button>
        </div>
      </template>
    </el-dialog>
  </div>

  <div v-else>
    <el-form-item :label="$t('plus.reject_reason')" :label-width="formLabelWidth"
      ><el-input v-model="reject_reason" :placeholder="$t('plus.input_content')"></el-input
    ></el-form-item>
  </div>
</template>

<script>
import PlusApi from "@/api/plus.js";
export default {
  data() {
    return {
      status: "",
      rejectReason: "",
      /*左边长度*/
      formLabelWidth: "120px",
      /*是否显示*/
      dialogVisible: false
    };
  },
  props: ["open_edit", "form"],
  created() {
    this.dialogVisible = this.open_edit;
    this.status = this.form.applyAtatus;
    if (this.status == 30) {
      this.rejectReason = this.form.rejectReason;
    }
  },
  methods: {
    /*修改*/
    editApplyStatus() {
      let self = this;
      let params = this.form;
      PlusApi.cashSubmit(params, true).then(data => {
        ElMessage({
          message: $t("plus.edit_success"),
          type: "success"
        });
        self.dialogFormVisible(true);
      }).catch(error => {});
    },
    /*关闭弹窗*/
    dialogFormVisible(e) {
      console.log(e);
      if (e) {
        this.$emit("closeDialog", {
          type: "success",
          openDialog: false
        });
      } else {
        this.$emit("closeDialog", {
          type: "error",
          openDialog: false
        });
      }
    }
  }
};
</script>

